<template>
	<view class="page">
		<view class="flex benben-position-layout flex flex-wrap align-center personalInformation_flex_0"
			:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between flex-sub personalInformation_fd0_0'>
				<view class='flex flex-wrap align-center' @tap.stop="handleJumpDiy" data-type="back" data-url="1">
					<text class='fu-iconfont2  personalInformation_fd0_0_c0_c0' @tap.stop="handleJumpDiy"
						data-type="back" data-url="1">&#xE794;</text>
				</view>
				<text class='personalInformation_fd0_0_c1'>完善信息</text>
				<view class='flex flex-wrap align-center personalInformation_fd0_0_c2'>
				</view>
			</view>

		</view>
		<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
		<view class="loading_css" v-if="isShow">
			<u-loading size="36" color="#1A66FA"></u-loading>
			<view>加载中</view>
		</view>
		<template v-else>
			<view class="page_content">
				<view class="content_info">
					<view class="content_title flex align-center justify-between">
						<view class="title_le">识别行驶证快速添加</view>
						<view class="title_ri">
							<!-- <text>完善信息</text>
							<u-icon name="arrow-right" size="24"></u-icon> -->
						</view>
					</view>
					<!-- <view class="img_title">证件图片</view>
					<view class="img_list flex align-center justify-between">
						<view class="img_item" v-if="detailsInfo.xsz_front_url">
							<image :src='detailsInfo.xsz_front_url' mode="aspectFill" @tap.stop="previewImage(detailsInfo.xsz_front_url)"></image>
							<view class="img_tag flex align-center justify-center">行驶证正页</view>
						</view>
						<view class="img_item" v-if="detailsInfo.xsz_back_url">
							<image :src='detailsInfo.xsz_back_url' mode="aspectFill" @tap.stop="previewImage(detailsInfo.xsz_back_url)"></image>
							<view class="img_tag flex align-center justify-center">行驶证副页</view>
						</view>
					</view> -->
					<view class="cards">
						<view class="cards_item">
							<view class="cards_item_img" @tap.stop="uploadImg(1)">
								<template v-if="!detailsInfo.xsz_url">
									<image mode="aspectFill" :src='STATIC_URL+"261.png"'></image>
									<image class="add_icon" mode="aspectFill" :src='STATIC_URL+"255.png"'></image>
								</template>
								<template v-else>
									<image mode="aspectFill" :src='detailsInfo.xsz_url'></image>
								</template>
							</view>
							<view class="cards_item_tip">上传行驶证照片</view>
						</view>
						<view class="cards_item">
							<view class="cards_item_img" @tap.stop="uploadImg(2)">
								<template v-if="!detailsInfo.insure_url">
									<image mode="aspectFill" :src='STATIC_URL+"262.png"'></image>
									<image class="add_icon" mode="aspectFill" :src='STATIC_URL+"255.png"'></image>
								</template>
								<template v-else>
									<image mode="aspectFill" :src='detailsInfo.insure_url'></image>
								</template>
								
							</view>
							<view class="cards_item_tip">上传保险照片</view>
						</view>
					</view>
					<!-- <view class="img_title">车辆图片</view>
					<view class="img_list">
						<view class="img_item">
							<image :src='STATIC_URL+"402.png"' mode="aspectFill"></image>
						</view>
					</view> -->
				</view>
				<view class="content_info">
					<view class="content_title flex align-center justify-between">
						<view class="title_le">车辆信息手动添加</view>
						<view class="title_ri"></view>
					</view>
					<view class="item_info flex align-center justify-between">
						<view class="item_info_le">车身颜色</view>
						<!-- <view class="item_info_ri">{{detailsInfo.color}}</view> -->
						<input class="item_info_ri" type="text" v-model="detailsInfo.color" placeholder="请输入车身颜色" placeholder-style="font-size:28rpx;color: #999;">
					</view>
					<view class="item_info flex align-center justify-between">
						<view class="item_info_le">发动机号</view>
						<input class="item_info_ri" type="text" v-model="detailsInfo.engine_no" placeholder="请输入发动机号" placeholder-style="font-size:28rpx;color: #999;">
					</view>
					<view class="item_info flex align-center justify-between">
						<view class="item_info_le">车架号</view>
						<input class="item_info_ri" type="text" v-model="detailsInfo.carframe" placeholder="请输入车架号" placeholder-style="font-size:28rpx;color: #999;">
					</view>
					<view class="item_info flex align-center justify-between" @tap.stop="pickerDiy1658997072074=true">
						<view class="item_info_le">注册时间</view>
						<input class="item_info_ri" type="text" v-model="detailsInfo.register_time" placeholder="请选择注册时间" :disabled="true" placeholder-style="font-size:28rpx;color: #999;">
						<u-icon name="arrow-right" color="#999" size="26"></u-icon>
					</view>
					<view class="item_info no_line flex align-center justify-between">
						<view class="item_info_le">保险电话</view>
						<!-- <view class="item_info_ri">{{detailsInfo.color}}</view> -->
						<input class="item_info_ri" type="text" v-model="detailsInfo.insure_phone" placeholder="请输入保险电话" placeholder-style="font-size:28rpx;color: #999;" maxlength="-1">
					</view>
					<!-- <view class="item_info flex align-center justify-between">
						<view class="item_info_le">当前里程</view>
						<view class="item_info_ri">-</view>
					</view>
					<view class="item_info flex align-center justify-between">
						<view class="item_info_le">保险到期时间</view>
						<view class="item_info_ri">-</view>
					</view>
					<view class="item_info flex align-center justify-between">
						<view class="item_info_le">保养到期时间</view>
						<view class="item_info_ri">-</view>
					</view>
					<view class="item_info no_line flex align-center justify-between">
						<view class="item_info_le">车检时间</view>
						<view class="item_info_ri">2025.12.10</view>
					</view> -->
				</view>
				
				
				<!-- <view class="del_btn flex align-center justify-center">删除</view> -->
			</view>
		</template>
		<view class="flex align-center justify-between feedback_flex_4" @tap.stop="saveContact">
			<view class='feedback_fd4_0'>保存</view>
		
		</view>
		
		
		<benben-picker ref="benbenWritePickerCodepicker2" :visible.sync="pickerDiy1658997072074"
			:value.sync='detailsInfo.register_time' endYear="现在" fields="day" mode='date' :mask-show='true' :timeout='true'
			:picker-height='100' default-type='value'>
			<template #picker-header>
				<view class='flex flex-wrap align-center justify-between personalInformation_picker2_0'>
					<view class="personalInformation_picker2_0_c1">注册时间</view>
					<u-icon @tap="$refs.benbenWritePickerCodepicker2.cancel()" name="close" color="#CCCCCC"></u-icon>
				</view>
			</template>
			<template #picker-footer>
				<view class="bill_picker_btn flex align-center justify-between">
					<view class="bill_picker_btn_1 flex align-center justify-center" @tap="$refs.benbenWritePickerCodepicker2.cancel()">取消</view>
					<view class="bill_picker_btn_2 flex align-center justify-center" @tap="$refs.benbenWritePickerCodepicker2.pickerConfirm()">确定</view>
				</view>
			</template>
		</benben-picker>
	</view>
</template>
<script>
	import UploadImage from '@/common/utils/upload-image.js'
	import {
		validate
	} from '@/common/utils/validate.js'
	export default {
		components: {},

		data() {
			return {
				pickerDiy1658997072074: false,
				id: "",
				isShow: true,
				detailsInfo: {},
				is_submit: false,
			};
		},
		computed: {
			
		},
		watch: {},
		onLoad(options) {
			let { id } = options;
			if (id !== undefined) this.id = id;
			this.getCarDetail();
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			getCarDetail() {
				this.$api.get(global.apiUrls.postCarDetail, {
					id: this.id
				}).then(res => {
					// console.log(res);
					this.isShow = false;
					if (res.data.code == 1) {
						this.detailsInfo = res.data.data;
					} else {
						this.$message.info(res.data.info);
					}
				})
			},
			// 图片上传
			uploadImg(type) {
				let _this = this;
				uni.chooseImage({
					count: 1,
					sourceType: ['album', 'camera'],
					success: (chooseImageRes) => {
						const tempFilePaths = chooseImageRes.tempFilePaths;
						uni.showLoading({
							title: '上传中'
						})
						uni.uploadFile({
							url: global.BASE_URL + global.apiUrls.postUpload, //仅为示例，非真实的接口地址
							filePath: tempFilePaths[0],
							name: 'image',
							formData: {
								image: 'image',
								type: 6,
								user_id: global.userInfo.id
							},
							success: (uploadFileRes) => {
								uni.hideLoading();
								let result = JSON.parse(uploadFileRes.data);
								console.log(result);
								if (result.code == 1) {
									if (type == 1) {
										_this.detailsInfo.xsz_url = result.data.data.file_url;
									} else if (type == 2) {
										_this.detailsInfo.insure_url = result.data.data.file_url;
									}
								}
							},
							fail: (err) => {
								console.log(err);
								uni.hideLoading();
								_this.$message.info('图片上传失败，请重试');
							}
						});
					}
				});
			},
			// 保存信息
			saveContact() {
				if (this.is_submit) return;
				if (!this.detailsInfo.xsz_url) {
					this.$message.info('请上传行驶证照片');
					return;
				}
				if (!this.detailsInfo.insure_url) {
					this.$message.info('请上传保险照片');
					return;
				}
				if (!this.detailsInfo.insure_phone) {
					this.$message.info('请输入保险电话');
					return;
				}
				this.is_submit = true;
				this.$api.post(global.apiUrls.addCarInfo, {
					id: this.id,
					xsz_url: this.detailsInfo.xsz_url,
					insure_url: this.detailsInfo.insure_url,
					color: this.detailsInfo.color,
					engine_no: this.detailsInfo.engine_no,
					carframe: this.detailsInfo.carframe,
					register_time: this.detailsInfo.register_time,
					insure_phone: this.detailsInfo.insure_phone
				}).then(res => {
					this.$message.info(res.data.info);
					if (res.data.code == 1) {
						setTimeout(() => {
							uni.navigateBack();
						}, 800)
					} else {
						this.is_submit = false;
					}
				}).catch(err => {
					this.is_submit = false;
				})
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page_content {
		padding: 0 24rpx 16rpx;
		.content_info {
			background: #fff;
			border-radius: 16rpx;
			padding: 0 24rpx 16rpx;
			margin-top: 16rpx;
		}
		.del_btn {
			width: 100%;
			height: 96rpx;
			background: #FFFFFF;
			border-radius: 16rpx;
			font-weight: 500;
			font-size: 30rpx;
			color: #FF532E;
			margin: 16rpx 0 32rpx;
		}
		.content_title {
			padding: 30rpx 0 24rpx;
			border-bottom: 1px solid #eee;
			.title_le {
				font-weight: bold;
				font-size: 30rpx;
				color: #000000;
			}
			.title_ri {
				font-weight: 400;
				font-size: 28rpx;
				color: #1A66FA;
			}
		}
		.item_info {
			padding: 26rpx 0;
			border-bottom: 1px solid #eee;
			.item_info_le {
				font-weight: 400;
				font-size: 28rpx;
				color: rgba(0,0,0,0.6);
			}
			.item_info_ri {
				flex: 1;
				text-align: right;
				font-weight: 500;
				font-size: 28rpx;
				color: rgba(0,0,0,0.8);
			}
		}
		.img_title {
			font-weight: 400;
			font-size: 28rpx;
			color: #000000;
			padding: 18rpx 0;
		}
		.img_list {
			overflow: hidden;
			.img_item {
				width: 320rpx;
				height: 240rpx;
				margin-bottom: 16rpx;
				position: relative;
				image {
					width: 100%;
					height: 100%;
					border-radius: 16rpx;
				}
				.img_tag {
					width: 100%;
					height: 50rpx;
					border-radius: 0 0 16rpx 16rpx;
					position: absolute;
					left: 0;
					bottom: 0;
					background: rgba(0, 0, 0, 0.6);
					font-size: 24rpx;
					color: #fff;
				}
			}
			.img_item:nth-child(2n+2) {
				margin-right: 0;
			}
		}
		.no_line {
			border-bottom: 0;
		}
	}
	.cards {
		display: flex;
		align-items: center;
		justify-content: space-between;
		.cards_item {
			.cards_item_img {
				width: 320rpx;
				height: 168rpx;
				position: relative;
				image {
					width: 100%;
					height: 100%;
					border-radius: 8rpx;
				}
				.add_icon {
					width: 74rpx;
					height: 74rpx;
					position: absolute;
					top: 50%;
					left: 50%;
					transform: translate(-50%, -50%);
				}
			}
			.cards_item_tip {
				text-align: center;
				font-weight: 400;
				font-size: 24rpx;
				color: #222222;
				margin-top: 20rpx;
			}
		}
	}
	.feedback_fd4_0 {
		width: 702rpx;
		height: 96rpx;
		line-height: 96rpx;
		text-align: center;
		background: #1A66FA;
		color: #ffffff;
		font-size: 30rpx;
		font-weight: 500;
		border-radius: 16rpx;
	}
	
	.feedback_flex_4 {
		width: 750rpx;
		height: 120rpx;
		overflow: hidden;
		position: fixed;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
		display: flex;
		justify-content: center;
		background: #fff;
	}
	.personalInformation_picker2_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		padding: 40rpx 30rpx 30rpx 30rpx;
		border-radius: 16rpx 16rpx 0rpx 0rpx;
	}
	
	.personalInformation_picker2_0_c0 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #BFBFBF;
	}
	
	.personalInformation_picker2_0_c1 {
		font-weight: bold;
		font-size: 34rpx;
		color: #000000;
	}
	.bill_picker_btn {
		background: #fff;
		padding: 12rpx 30rpx 28rpx;
	}
	.bill_picker_btn_1 {
		width: 236rpx;
		height: 96rpx;
		background: #F6F7FB;
		border-radius: 16rpx;
		font-weight: 500;
		font-size: 30rpx;
		color: #222222;
	}
	.bill_picker_btn_2 {
		width: 436rpx;
		height: 96rpx;
		background: #1A66FA;
		border-radius: 16rpx;
		font-weight: 500;
		font-size: 30rpx;
		color: #fff;
	}
	
	
	.personalInformation_picker2_0 {
		border-bottom: 1px solid #eee;
		background: #fff;
		background-size: 100% !important;
		padding: 0rpx 32rpx 0rpx 32rpx;
		border-radius: 16rpx 16rpx 0rpx 0rpx;
		background-size: 100% auto !important;
		height: 100rpx;
	}

	.personalInformation_picker2_0_c0 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #BFBFBF;
	}

	.personalInformation_picker2_0_c1 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
	}

	.personalInformation_picker2_0_c2 {
		color: rgba(44, 143, 255, 1);
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 400;
	}

	.personalInformation_fd1_0 {
		// margin-top: 32rpx;
		height: 96rpx;
		border-top: 1px solid #eee;
	}

	.personalInformation_fd1_0_c0 {
		font-weight: 400;
		font-size: 28rpx;
		color: rgba(0,0,0,0.6);
	}

	.personalInformation_fd1_0_c1_image {
		width: 72rpx;
		height: 72rpx;
		border-radius: 50%;
	}

	.personalInformation_fd1_1 {
		border-bottom: 1px solid #eee;
		height: 109rpx;
	}

	.personalInformation_fd1_1_c0 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
	}

	.personalInformation_fd1_1_c1 {
		font-weight: 400;
		font-size: 28rpx;
		color: #222222;
		text-align: right;
		margin: 0rpx 0rpx 0rpx 24rpx;
	}

	.personalInformation_fd1_2 {
		border-bottom: 1px solid #eee;
		height: 109rpx;
	}

	.personalInformation_fd1_2_c0 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
	}

	.personalInformation_fd1_2_c1 {
		font-size: 32rpx;
		font-weight: 400;
		color: #333;
		text-align: right;
		margin: 0rpx 0rpx 0rpx 24rpx;
	}

	.personalInformation_fd1_3 {
		border-bottom: 1px solid #eee;
		height: 109rpx;
	}

	.personalInformation_fd1_3_c0 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
	}

	.personalInformation_fd1_3_c1 {
		font-weight: 500;
		font-size: 28rpx;
		color: rgba(0,0,0,0.8);
	}

	.personalInformation_flex_1 {
		background: #fff;
		border-radius: 16rpx;
		padding: 24rpx 24rpx 0rpx 24rpx;
		margin: 16rpx 24rpx 0;
	}

	.personalInformation_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
		height: 88rpx;
	}

	.personalInformation_fd0_0_c0_c0 {
		font-size: 32rpx;
		font-weight: 500;
		color: #111;
	}

	.personalInformation_fd0_0_c1 {
		font-size: 32rpx;
		font-weight: bold;
		color: #111111;
	}

	.personalInformation_fd0_0_c2 {
		width: 36rpx;
		height: 36rpx;
	}

	.personalInformation_flex_0 {
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background: url(https://speed.zhongchuxing.com/gjdimages/page_bg.png) no-repeat;
		background-size: 100% auto !important;
	}

	.page {
		min-height: calc(100vh - var(--window-bottom));
		background: url(https://speed.zhongchuxing.com/gjdimages/page_bg.png) no-repeat #f6f7fb;
		background-size: 100% auto !important;
	}
</style>